A virtual machine (VM) is a portion of software that, when executed on appropriate hardware, creates an environment allowing the virtualization of an actual physical computer system. Each VM may function as a self-contained platform, running its own operating system (OS) and software applications (processes). A host machine (e.g., computer or server) is typically enabled to simultaneously run one or more VMs, where each VM may be used by a local or remote client. The host machine allocates a certain amount of the host's resources to each of the VMs. Each VM may use the allocated resources to execute applications, including OSs known as guests or guest OSs. The hypervisor virtualizes the underlying hardware of the host machine or emulates hardware devices, making the use of the VM transparent to the guest OS or the remote client that uses the VM. Typically, a hypervisor manages allocation and virtualization of computer resources and performs context switching, as may be necessary, to cycle between various VMs.
An emulated device is a virtual device within a VM that mimics a physical hardware device. For emulated devices, a guest sends a request to the hypervisor and the hypervisor interprets the request and executes it on behalf of the guest. With an emulated device, the emulation can run on any physical server, independent of the specifics of the physical device. An emulated device may refer to a device that is implemented by the hypervisor and is exposed to the guest as part of the VM. In an example, the emulated device may be a purely virtual device that mimics real hardware. In such an example, the emulated device may be implemented using full emulation such that the device driver to which the emulated device is assigned may work on the hardware coupled to the host machine. In another example, the emulated device may be a paravirtualized device that is controlled by a device driver that is written for a specific hypervisor. In such an example, the emulated device may be implemented using paravirtualization such that the device driver to which the emulated device is assigned does not work on the hardware coupled to the host machine.
In emulation, no direct requirement exists for virtual and physical devices to be similar, and an access request by the guest can be executed by the hypervisor on behalf of the guest. Accordingly, a migrating VM continues to view the same set of virtual devices across the migration. An emulated device may provide uniformity, with the emulation layer masking any diversity at the level of the physical device. The virtual device may look the same in the source and destination host machines, and the VM may be migrated to another host machine because the guest is using a virtual device that does not need to look like a physical device.
An assigned device is a physical device that is exposed to a guest as part of the VM and may also be known as a pass-through device. An assigned device is also known as a pass-through device because the hypervisor acts as a “pass-through” for communications between the VM and host machine. Device assignment allows the guest running on the VM to have direct access to the assigned device. The hypervisor may assign a device to a VM running on a host machine. The overhead of virtualization is low because a big portion of the functionality for accessing the assigned device is running within the VM. Accordingly, device assignment may result in faster performance compared to the guest accessing an emulated device. Assigning a device to the VM, however, may have some disadvantages. For example, it may be difficult to migrate a VM from one host machine to another because the specificity of a physical device on the physical server becomes exposed to guest software. For assigned devices, a guest sends a request to the hypervisor and the hypervisor passes the request along to a backend device without interpreting the request. It may be difficult to migrate a VM to which a device is assigned because the source hypervisor may not be able to reliably retrieve the state of the assigned device and send the state of the assigned device to the destination hypervisor.